<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <title>排他操作</title>
</head>

<body>
    <input type="button" value="按钮1">
    <input type="button" value="按钮2">
    <input type="button" value="按钮3">
    <input type="button" value="按钮4">
    <input type="button" value="按钮5">
    <input type="button" value="按钮6">
    <input type="button" value="按钮7">
</body>
<script>
    var bot1 = document.getElementsByTagName('input');
    console.log(bot1);
    for (var i = 0; i < bot1.length; i++) {
        bot1[i].onclick = function() {
            for (var j = 0; j < bot1.length; j++) {
                bot1[j].style.backgroundColor = '';
            }
            this.style.backgroundColor = 'red'

        }
    }
</script>

</html>